import {ApiProperty} from "@nestjs/swagger";
import {ArrayMinSize, IsArray, IsDefined, IsNumber, Length, ValidateNested} from "class-validator";
import {IsFile} from "~/modules/tools/upload/file.constraint";
import {MultipartFile} from "@fastify/multipart";
import {Type} from "class-transformer";

export class StaffSaveDto {
  @ApiProperty({type: 'string', format: 'binary', description: '头像', required: true})
  @IsDefined()
  @IsFile(
    {
      mimetypes: [
        'image/png',
        'image/gif',
        'image/jpeg',
        'image/webp',
        'image/svg+xml',
      ],
      fileSize: 1024 * 1024 * 10,
    },
    {
      message: '文件类型不正确',
    },
  )
  file: MultipartFile

  @ApiProperty({description: '姓名', required: true})
  @IsDefined()
  @Length(1, 10, {message: '姓名长度为1-10个字符'})
  name: string

  @ApiProperty({description: '简介', required: false})
  @IsDefined()
  description: string

  @ApiProperty({description: '手机号', required: true})
  @IsDefined()
  mobile: string

  @ApiProperty({description: '评分'})
  @Type(() => Number)
  @IsDefined()
  score: number
}

export class StaffDelDto {
  @ApiProperty({description: '咨询师ID', type: Number, required: true})
  @IsDefined()
  @Type(() => Number)
  @IsNumber({}, { message: '咨询师ID必须为数字' })
  id: number
}

export class StaffRelateTags {
  @ApiProperty({description: '咨询师ID', type: Number, required: true})
  @IsDefined()
  @Type(() => Number)
  @IsNumber({}, { message: '咨询师ID必须为数字' })
  staffId: number

  @ApiProperty({description: '标签ID列表', type: [Number], required: true})
  @IsDefined()
  // 判断tags列表长度
  @IsArray()
  @ArrayMinSize(1, { message: '标签列表不能为空' }) // 确保列表至少有一个元素
  tags: number[]
}
